const express = require('express');
const router = express.Router();
// const data = require('../views/json/user_info.json');
const common = require('./common');

// const  connection = mysql.createConnection({
//   host     : 'localhost',
//   user     : 'root',
//   password : '',
//   database : 'gonghui'
// })
const connection = common.mysqlConfig
//执行数据库连接
// connection.connect();
/* GET users listing. */
router.get('/', (req, res, next) => {
  const sql = 'SELECT * FROM USER';
  connection.query(sql, (err, result) => {
    // 封装公共返回方法
    const data = common.resCommon(err, result);
    res.json(data)
  });
});

module.exports = router;
